#include <bits/stdc++.h>
using namespace std;
const int N=10050;
int n,xi,yi;
int a[N],b[N],x[N],y[N];
int main(void){
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d%d%d%d",&a[i],&b[i],&x[i],&y[i]);
    }
    scanf("%d%d",&xi,&yi);
    for(int i=n;i>0;i--){
        if(a[i]<=xi && a[i]+x[i]>=xi && b[i]<=yi && b[i]+y[i]>=yi){
            printf("%d\n",i);
            return 0;
        }
    }
    printf("-1\n");
    return 0;
}